from turtle import pensize


class Student(object):

    # 类属性 ‘静态变量’实例共享 可被实例属性覆盖
    age=10

    @property
    def birth(self):
        return self._birth

    @birth.setter
    def birth(self,value):
        self.birth=value

    def __init__(self,name,score):
        # 实例属性
        self.name=name
        self.score=score
        # 私有
        self.__pname=name
        self.a, self.b = 0, 1

    def echo (self):
        print("A %s B %s" % (self.name ,self.score))

    def __str__(self) -> str:
        print("Tostring")

    __repr__=__str__

    def __iter__(self):
        return self # 实例本身就是迭代对象，故返回自己

    def __next__(self):
        self.a, self.b = self.b, self.a + self.b # 计算下一个值
        if self.a > 100000: # 退出循环的条件
            raise StopIteration()
        return self.a # 返回下一个值

s = Student("Emma",100)
s.echo()

print(isinstance(s,Student))

print(dir(s))
print(hasattr(s,'attrA'))
print(getattr(s,'name'))
print(setattr(s,'name','666'))